{include file='admin/header.html'}

<!-- 搜索框 -->
<div class="layui-form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.title}</label>
            <div class="layui-input-block">
                <input type="text" name="title" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.slug}</label>
            <div class="layui-input-block">
                <input type="text" name="slug" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.description}</label>
            <div class="layui-input-block">
                <input type="text" name="description" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.category}</label>
            <div class="layui-input-block">
                <select name="category_id">
                    <option value="">{$tran.choose}</option>
                    {foreach from="$category_tree" item="_category"}
                    <option value="{$_category.id}">{$_category.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.status}</label>
            <div class="layui-input-block">
                <select name="status">
                    <option value="">{$tran.choose}</option>
                    <option value="0">{$tran.normal}</option>
                    <option value="1">{$tran.disable}</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.author}</label>
            <div class="layui-input-block">
                <input type="text" name="author" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.date}</label>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="text" name="start" placeholder="yyyy-MM-dd" class="layui-input date">
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="text" name="end" placeholder="yyyy-MM-dd" class="layui-input date">
            </div>
        </div>
        <div class="layui-inline">
            <button type="submit" lay-submit lay-filter="search"
                class="layui-btn layui-icon layui-icon-search"></button>
        </div>
    </div>
</div>

<!-- 数据表格 -->
<table id="dataTable" lay-filter="dataTable"></table>

<!-- 头工具栏 -->
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm layui-icon layui-icon-delete" title="{$tran.delall}" lay-event="delAll"></button>
        <button class="layui-btn layui-btn-sm layui-icon layui-icon-addition" title="{$tran.add}" lay-event="add2"></button>
        <button class="layui-btn layui-btn-sm layui-icon layui-icon-refresh" title="{$tran.refresh}" lay-event="refresh"></button>
    </div>
</script>

<!-- dataTable render -->
<script>
    var render = {
        elem: '#dataTable',
        toolbar: '#toolbar',
        defaultToolbar: ['filter', 'exports', 'print'],
        cellMinWidth: 80,
        height: 'full',
        where: { search: '' }, //搜索
        title: '{$tran.article_list}', //数据表格标题
        page: true, //开启分页
        cols: [[
            { type: 'checkbox', fixed: 'left' },
            { field: 'id', title: 'ID', sort: true, width: 80 },
            { field: 'title', title: '{$tran.title}', event: 'title', style: 'cursor: pointer;', sort: true },
            { field: 'slug', title: '{$tran.slug}', event: 'slug', style: 'cursor: pointer;', sort: true },
            { field: 'cover', title: '{$tran.cover}', event: 'cover', style: 'cursor: pointer;', sort: true },
            { field: 'description', title: '{$tran.description}', sort: true, event: 'description', style: 'cursor: pointer;' },
            { field: 'category', title: '{$tran.category}', sort: true },
            { field: 'tags', title: '{$tran.tag}', sort: true },
            { field: 'views', title: '{$tran.view}', sort: true, edit: 'text' },
            { field: 'likes', title: '{$tran.likes}', sort: true, edit: 'text' },
            { field: 'author', title: '{$tran.author}', sort: true, edit: 'text' },
            {
                field: 'status', title: '{$tran.status}', sort: true, width: 90, templet: function (d) {
                    return '<input type="checkbox" name="status" lay-filter="status" value="' + d.id + '" lay-skin="switch" lay-text="ON|OFF"' + (d.status == 0 ? ' checked' : '') + '>';
                }
            },
            {
                field: 'can_comment', title: '{$tran.comment}', sort: true, width: 90, templet: function (d) {
                    return '<input type="checkbox" name="can_comment" lay-filter="can_comment" value="' + d.id + '" lay-skin="switch" lay-text="ON|OFF"' + (d.can_comment == 0 ? ' checked' : '') + '>';
                }
            },
            { field: 'create_at', title: '{$tran.create_at}', sort: true },
            { field: 'update_at', title: '{$tran.update_at}', sort: true },
            {
                title: '{$tran.option}', align: 'center', width: 125, templet: function (d) {
                    return '<button class="layui-btn layui-btn-primary layui-btn-xs layui-icon layui-icon-release" title="{$tran.read}" lay-event="read"></button>' +
                        '<button class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" title="{$tran.edit}" lay-event="edit2"></button>' +
                        '<button class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" title="{$tran.delete}" lay-event="del"></button>';
                }
            }
        ]]
    }
</script>

{include file='admin/inc/dataTable.html'}

{include file='admin/footer.html'}